package com.seari.vehbaseP.web.controller;

import com.seari.vehbaseP.bean.CommonPartResponse;
import com.seari.vehbaseP.service.BaseInfoService;
import com.seari.vehbaseP.service.DeviceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "")
public class BaseInfoController {

    @Autowired
    BaseInfoService baseInfoService;

    /**
     * 获取基地信息
     * @return
     */
    @RequestMapping(value = "/baseInfo",method = RequestMethod.POST)
    @ResponseBody
    public CommonPartResponse getAllBaseInfo(){
        return baseInfoService.searchBaseInfo();
    }

    /**
     * 查询基地信息
     * @return
     */
    @RequestMapping(value = "/baseInfoMatch",method = RequestMethod.POST)
    @ResponseBody
    public CommonPartResponse getAllBaseInfo(@RequestParam(value = "page")String page,@RequestParam(value = "limit")String limit,@RequestParam(value = "match")String match){
        int start = (Integer.parseInt(page) - 1) * Integer.parseInt(limit);
        int li = Integer.parseInt(limit);
        return baseInfoService.searchMatch(match,start,li);
    }

    /**
     * 查询项目下某设备全部参数描述
     * @param projectCode
     * @param deviceId
     * @return
     */
    @RequestMapping(value = "/deviceParam",method = RequestMethod.POST)
    @ResponseBody
    public CommonPartResponse getAllDeviceParam(@RequestParam(value = "ProjectCode")String projectCode,@RequestParam(value = "DeviceId")String deviceId){
        return  baseInfoService.searchDeviceParam(projectCode,deviceId);
    }
}